package com.yuyou.tas.lesson.service.comm;

import com.yuyou.tas.service.api.admin.service.AuthUserAPI;
import com.yuyou.tas.util.bean.LoginRedisObj;
import com.yuyou.tas.util.enums.admin.AuthUserEnums;
import com.yuyou.tas.util.exception.BusinessException;
import com.yuyou.tas.util.message.CommMess;
import com.yuyou.tas.util.tool.LoginRedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class Subj7SectLimitService {
	@Autowired
	private AuthUserAPI authUserAPI;

	public void checkByUserId(Long userId, Long subjuectId,Long sectionId) throws Exception {
		LoginRedisObj redisObj=LoginRedisUtil.getUserObj(userId);
		
		Integer userType=redisObj.getUserType();	
		if(redisObj.getIsManager()){
			return;
		}else{
			if(userType==AuthUserEnums.type.teacher.getValue()){
				return;
			}		
			if(userType==AuthUserEnums.type.registrar.getValue()){
				return;
			}
		}

		if(authUserAPI.findCountByParams(userId , subjuectId , sectionId) < 1){
			throw new BusinessException(CommMess.ERR_POWER);
		}
		/*if(!redisObj.getDataSubjects().contains(subjuectId)){
			throw new Exception(CommMess.ERR_POWER);
		}
		if(!redisObj.getBaseSectionIds().contains(sectionId)){
			throw new Exception(CommMess.ERR_POWER);
		}*/
		
	}
	



}
